package org.example.controller;

import cn.hutool.core.bean.BeanUtil;
import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletRequest;
import org.example.Contant.BusinessException;
import org.example.Contant.Result;
import org.example.dto.UserDto;
import org.example.entity.User;
import org.example.service.ChatService;
import org.example.service.impl.ChatServiceImpl;
import org.example.util.JwtUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;


@Controller
@RequestMapping("/api")
public class ChatController {

    @Autowired
    private ChatService chatService;

    @GetMapping("/chat")
    public String chat() {
        return "chat";
    }

    /**
     * 获取当前用户
     * @param request
     * @return
     */
    @ResponseBody
    @GetMapping("/currentUser")
    public Result<UserDto> getCurrentUser(HttpServletRequest request){
        return chatService.getCurrentUser(request);
    }
}
